﻿using System;
using System.Text;

namespace Synology.DS.Common
{
	public class StringEncoder
	{
		public static string Encode(string str)
		{
			return Convert.ToBase64String(Encoding.ASCII.GetBytes(str));
		}

		public static string Decode(string str)
		{
			try
			{
				return Encoding.ASCII.GetString(Convert.FromBase64String(str));
			}
			catch (Exception)
			{
				return string.Empty;
			}
		}
	}
}
